package com.springaispringboot.controlller;

import org.springframework.ai.openai.OpenAiChatModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author Lsc
 * @date 2025/3/29 14:20
 */
@RestController
@RequestMapping(value = "/chat", produces = "application/json;charset=UTF-8")
public class SpringAiChatController {

    @Autowired
    private OpenAiChatModel openAiChatModel;

    @RequestMapping("/chat")
    public String chat(@RequestParam String message) {
        String call = openAiChatModel.call(message);
        return call;
    }
}
